$(document).ready(function(){
    window.error = function(msg){
        $.message({verticalOffset: -75,horizontalOffset: 0}).alert(msg);
    }
    window.alert = function(msg){
        $.message({verticalOffset: -75,horizontalOffset: 0}).alert(msg);
    }
    window.success = function(msg){
        $.message({verticalOffset: -75,horizontalOffset: 0}).info(msg);
    }
    window.dialog = function(msg){
        $.message({verticalOffset: -75,horizontalOffset: 0}).alert(msg);
    }
})
/**
 * 获得dom元素光标位置
 * @param obj
 * @returns {number}
 */
function getPosition(obj){
    var result = 0;
    if(obj.selectionStart != undefined){ //IE以外
        result = obj.selectionStart ;
    }else{ //IE
        var rng;
        if(obj.tagName == "textarea"){ //TEXTAREA
            rng = event.srcElement.createTextRang();
            rng.moveToPoint(event.x,event.y);
        }else{ //Text
            rng = document.selection.createRange();
        }
        rng.moveStart("character",-event.srcElement.value.length);
        result = rng.text.length;
    }
    return result;
}
/**
 * 设置元素光标位置
 * @param tObj
 * @param sPos
 */
function setCaretPosition(tObj, sPos){
    if(tObj.setSelectionRange){
        setTimeout(function(){
            tObj.setSelectionRange(sPos, sPos);
            tObj.focus();
        }, 0);
    }else if(tObj.createTextRange){
        var rng = tObj.createTextRange();
        rng.move('character', sPos);
        rng.select();
    }
}
/**
 * 获得事件源对象
 * @returns {EventTarget|event.target|*|Object}
 */
function getEtarget(){
    var evt = window.event || arguments.callee.caller.arguments[0];
    //evt.target 不支持ie10及以下浏览器 ||  evt.srcElement 不支持火狐浏览器
    var src = evt.target || evt.srcElement;
    return src;
}